import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Admin
 * Date: 2022-12-06
 * Time: 21:13
 */
public class Demo1 {
    public static int func(String m,String n) {
        int mlen = m.length();
        int nlen = n.length();

        int[][] array = new int[mlen+1][nlen+1];

        for(int i = 1; i <= mlen; i++) {
            for(int j = 1; j <= nlen; j++) {
                if(m.charAt(i-1) == n.charAt(j-1)) {
                    array[i][j] = array[i-1][j-1] + 1;
                }else {
                    array[i][j] = Math.max(array[i-1][j],array[i][j-1]);
                }
            }
        }

        return array[mlen][nlen];
    }

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        while(scan.hasNext()) {
            String str1 = scan.next();
            String str2 = scan.next();

            System.out.println(func(str1,str2));
        }
    }
}
